package com.apes.fn.scm.crossCompany.transfer.repository;

import com.apes.fn.scm.crossCompany.transfer.model.TransferBatch;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface TransferBatchRepository extends CustomRepository<TransferBatch, String> {

    @Query(value = "select * from cross_transfer_batch where transfer_item_id = :itemId order by create_date asc",nativeQuery = true)
    List<TransferBatch> findByItem(@Param("itemId") String itemId);

    @Query(value = "select * from cross_transfer_batch where transfer_id = :transferId",nativeQuery = true)
    List<TransferBatch> findByTransferId(@Param("transferId") String transferId);

    @Query("SELECT T FROM TransferBatch T WHERE crossCompanyTransfer.id = ?1 AND companyTransferItem.id = ?2")
    List<TransferBatch> findCanDelteTransferBatch(String transferId, String itemId);
}
